package logic

import (
	"context"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type PermissionsCreateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPermissionsCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PermissionsCreateLogic {
	return &PermissionsCreateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 权限添加
func (l *PermissionsCreateLogic) PermissionsCreate(in *user.PermissionsCreateRequest) (*user.PermissionsCreateResponse, error) {
	//调用业务逻辑
	permission, err := dao.PermissionsCreate(in)
	if err != nil {
		return nil, err
	}

	return &user.PermissionsCreateResponse{
		Id: int64(permission.Id),
	}, nil
}
